package com.clas.liu.myapplication.presenter.impl;

import android.os.Handler;
import android.os.Message;

import com.clas.liu.myapplication.model.entity.user.UserData;
import com.clas.liu.myapplication.model.event.RegisterEvent;
import com.clas.liu.myapplication.model.impl.BaseModel;
import com.clas.liu.myapplication.model.impl.EditUserInfoModel;
import com.clas.liu.myapplication.presenter.i.IEditUserInfoPresenter;
import com.clas.liu.myapplication.view.activity.impl.BaseActivity;
import com.clas.liu.myapplication.view.activity.impl.EditUserInfoActivity;

/**
 * Created by liu on 2019/5/22.
 */

public class EditUserInfoPresenter extends BasePresenter<EditUserInfoActivity,EditUserInfoModel> implements IEditUserInfoPresenter {
    public EditUserInfoPresenter(EditUserInfoActivity view) {
        super(view);
    }

    @Override
    public void editUser(UserData userData) {
        mModel.editUser(userData);
    }

    @Override
    protected EditUserInfoModel getModel(Handler handler) {
        return new EditUserInfoModel(handler);
    }

    @Override
    protected void eventReceive(Message msg) {
        switch (msg.what) {
            case RegisterEvent.EDIT_USER_FAIL:
                mView.failBecauseNetReturn(msg.what);
                break;
            case RegisterEvent.EDIT_USER_OK:
                mView.editReturn(((RegisterEvent)msg.obj).getUserRoot().getData());
                break;
        }
    }
}
